/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.vanniktech.vntnumberpickerpreference.sample;

import com.vanniktech.vntnumberpickerpreference.Constants;
import com.vanniktech.vntnumberpickerpreference.PreferenceUtils;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.app.Context;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * 文件描述
 *
 * @since 2021-05-26
 */
public class PreferenceUtilsTest {
    private Context context;

    /**
     * 开始
     *
     */
    @Before
    public void setUp() {
        context = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentTopAbility().getContext();
    }

    /**
     * 结束
     *
     */
    @After
    public void tearDown() {
        context = null;
    }

    /**
     * 存数据
     *
     */
    @Test
    public void putString() {
        PreferenceUtils.putString(context, Constants.FONT_SIZE, "25");
    }

    /**
     * 取数据
     *
     */
    @Test
    public void getString() {
        String string = PreferenceUtils.getString(context, Constants.FONT_SIZE, "0");
        System.out.println("-----------" + string);
    }

    /**
     * 删除数据
     *
     */
    @Test
    public void deleteString() {
        PreferenceUtils.deleteString(context, Constants.FONT_SIZE);
    }
}
